{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/newsflash/newsFlashlList')}">快讯列表</a></li>
            <li class="layui-this">编辑快讯</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/newsflash/update')}" method="post">
                    {:token()}
                    <input type="hidden" name="id" value="{$data.id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">快讯标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="{$data.name}" required  lay-verify="required" placeholder="请输入快讯标题(限制12字)" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">快讯标签</label>
                        <input type="hidden" name="" value="{$data.id}" id="newId">
                        <input type="hidden" name="label_ids" value="" id="label_ids_input" />
                        <div class="layui-input-block">
                            <div class="layui-input labeledit-bigbox">
                                <input class="labeledit-input"/>
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发布作者</label>
                        <div class="layui-input-block">
                            <input type="text" name="author" value="{$data.author}"lay-verify="required" class="layui-input layui-input-inline" id="ad_content_9">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">选择栏目</label>
                        <div class="layui-input-inline">
                            <select name="index_column_id"  lay-search="">
                                <option value="0">空</option>
                                <!--{foreach	name="column"	item="vo"	key="k"	}-->
                                {foreach	$column	as	$key=>$value}
                                <option value="{$value.id}" {if	condition="$data.index_column_id==$value.id"} selected  {/if} >{$value.column_name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">快讯来源</label>
                        <div class="layui-input-block">
                            <input type="text" name="source" value="{$data.source}"lay-verify="required" class="layui-input layui-input-inline">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发布时间</label>
                        <div class="layui-input-inline">
                            <input class="layui-input date"  placeholder="yyyy-MM-dd HH:mm:ss" name="publish_time" value="{$data.publish_time}" type="text">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">收藏人数</label>
                        <div class="layui-input-block">
                            <input type="text" name="number_collection" value="{$data.number_collection}"lay-verify="required" class="layui-input layui-input-inline">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">阅读人数</label>
                        <div class="layui-input-block">
                            <input type="text" name="number_reading" value="{$data.number_reading}"lay-verify="required" class="layui-input layui-input-inline">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">排序设置</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" value="{$data.sort}"lay-verify="required" class="layui-input layui-input-inline">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">发布平台</label>
                        <div class="layui-input-block">
                            {foreach name="$platform" item="val"}

                            <input type="checkbox" name="platform[]" lay-skin="primary"
                                   value="{$val.id}"
                                   title="{$val.platform_name}"
                                   {foreach name="$data.platform|unserialize" item="vo" key="k" }
                                   {if condition="$vo==$val.id"} checked="checked" {/if}
                            {/foreach}>

                            {/foreach}
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">显示设置</label>
                        <div class="layui-input-block">
                            {switch	name="data.status"}
                            {case	value="0"}
                            <input type="radio" name="status" value="0" title="下线" checked="checked">
                            <input type="radio" name="status" value="1" title="上线">
                            {/case}
                            {case	value="1"}
                            <input type="radio" name="status" value="0" title="下线">
                            <input type="radio" name="status" value="1" title="上线" checked="checked">
                            {/case}
                            {default	/}
                            <input type="radio" name="status" value="0" title="下线" checked="checked">
                            <input type="radio" name="status" value="1" title="上线">
                            {/switch}

                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">水印开关</label>
                        <div class="layui-input-block">
                            <input type="checkbox" name="close" lay-skin="switch" lay-filter="shuiying_switch" lay-text="开启|关闭">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">正文</label>
                        <div class="layui-input-block">
                            <textarea id="content_box" placeholder="" class="layui-textarea" name="synopsis">{$data.content}</textarea>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="">保存</button>
                            <div class="layui-btn" id="preview_btn">预览</div>
                            <input type="hidden" id="preview_data"/>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="iframe-bigbox" style="display: none;">
    <input id="packdata" type="hidden">
    <input id="iframe_url" type="hidden" value="__CSS__/wechat/detail_kuaixun.html"/>
    <div class="iframe-bigbox-mask"></div>
    <iframe id="iframe_box" src="" style=""></iframe>
</div>
{/block}
{block name="js"}
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>

    $(function() {

        //预览
        $("#preview_btn").on("click",function () {
            var packdata = {};
            packdata.name = $("input[name='name']").val();//标题
            packdata.author = $("input[name='author']").val();//作者
//            packdata.create_time = $("input[name='publish_time']").val();//发布时间
            packdata.content = $("textarea[name='synopsis']").parents(".layui-input-block").find("iframe")[0].contentWindow.document.body.innerHTML;//文章
            packdata.label_arr = [];//标签
            for(var i = 0; i < $(".list-label-new li").length; i++){
                packdata.label_arr.push({"label_name":$(".list-label-new li").eq(i).attr("data-name")});
            }
            packdata.img = "";//作者头像
            $("#packdata").val(JSON.stringify(packdata));
            $(".iframe-bigbox").fadeIn(300);
            $("#iframe_box").attr({"src":$("#iframe_url").val()});
            $(".iframe-bigbox-mask").on("click",function () {
                $(".iframe-bigbox").fadeOut(300);
                $("#iframe_box").attr({"src":""});
            });
        });

        content_init("shuiying_switch");
        relpace_link();

        layui.upload({
            url: "/api/file_upload/upload",
            before: function(obj){
                _loadshow("正在上传");
            },
            success: function (data) {
                _loadhide();
                if (data.error === 0 && data.type === 'image') {
                    document.getElementById('Cover_Ad').value = data.url;
                    var _ad_index_img_box = $(".ad_index_img_box");//上传图片显示盒子
                    _ad_index_img_box.empty();
                    _ad_index_img_box.append(
                        '<img style="display: block; width: 92px;" src="' + data.url + '"/>'
                    );
                } else {
                    layer.msg(data.message);
                }
            }
        });

        $('.date').on('click', function () {
            laydate({
                elem: this
                ,format: 'YYYY-MM-DD hh:mm:ss'
                ,type: 'datetime'
            })
        });
    });
    read_label(5);
    labeledit_fun();
</script>

{/block}